lib/repo: Minor cleanup to object import function
authorColin Walters <walters@verbum.org>
Mon, 18 Sep 2017 19:46:03 +0000 (15:46 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 19 Sep 2017 18:51:03 +0000 (18:51 +0000)
We have a lot of layers of abstraction here; let's fold in the `trusted`
conditional into the call, since that's all the public API we're using does
anyways.

Prep for a future patch around object copying during imports.

Closes: #1187
Approved by: jlebon

src/libostree/ostree-repo.c

index f779db85ee0bb5701966f5faa31f97a793820d85..440d2bf9b40cf7130c2f9a8027865b838e0523e9 100644 (file)
@@ -3598,23 +3598,12 @@ ostree_repo_import_object_from_with_trust (OstreeRepo           *self,
                                      &variant, error))
         return FALSE;
 
-      if (trusted)
-        {
-          if (!ostree_repo_write_metadata_trusted (self, objtype,
-                                                   checksum, variant,
-                                                   cancellable, error))
-            return FALSE;
-        }
-      else
-        {
-          g_autofree guchar *real_csum = NULL;
-
-          if (!ostree_repo_write_metadata (self, objtype,
-                                           checksum, variant,
-                                           &real_csum,
-                                           cancellable, error))
-            return FALSE;
-        }
+      g_autofree guchar *real_csum = NULL;
+      if (!ostree_repo_write_metadata (self, objtype,
+                                       checksum, variant,
+                                       trusted ? NULL : &real_csum,
+                                       cancellable, error))
+        return FALSE;
     }
   else
     {
@@ -3627,22 +3616,12 @@ ostree_repo_import_object_from_with_trust (OstreeRepo           *self,
                                            cancellable, error))
         return FALSE;
 
-      if (trusted)
-        {
-          if (!ostree_repo_write_content_trusted (self, checksum,
-                                                  object_stream, length,
-                                                  cancellable, error))
-            return FALSE;
-        }
-      else
-        {
-          g_autofree guchar *real_csum = NULL;
-          if (!ostree_repo_write_content (self, checksum,
-                                          object_stream, length,
-                                          &real_csum,
-                                          cancellable, error))
-            return FALSE;
-        }
+      g_autofree guchar *real_csum = NULL;
+      if (!ostree_repo_write_content (self, checksum,
+                                      object_stream, length,
+                                      trusted ? NULL : &real_csum,
+                                      cancellable, error))
+        return FALSE;
     }
 
   return TRUE;